<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			
			ul,li{
				list-style: none;
			}
		</style>
	</head>
	<body>
		<ul id="god">

		</ul>
		<script type="text/javascript">
			var goodlist = [{
					id: 111,
					url: '../images/g1.jpg',
					name: '阿联酋美女1号',
					price: 1998,
					age: 20
				},
				{
					id: 22,
					url: '../images/g2.jpg',
					name: '阿联酋美女2号',
					price: 98,
					age: 18
				},
				{
					id: 3325,
					url: '../images/g3.jpg',
					name: '阿联酋美女3号',
					price: 998,
					age: 22
				},
				{
					id: 4,
					url: '../images/g4.jpg',
					name: '阿联酋美女4号',
					price: 9.8,
					age: 24
				},
				{
					id: 5,
					
					url: '../images/g3.jpg',
					name: '阿联酋美女5号',
					price: 9888,
					age: 18
				}
			]
			//获取url的参数 

			var p = location.search; //?id=111&name=阿联酋美女1号  {id:111,name:'阿联酋美女1号}
			//
			p = p.substring(1) //把 ? 号 截取
			//将字符串转换成数组
			var arr = p.split('=');
			//将数组在转换为对象
			var obj = {};
			obj[arr[0]] = arr[1];
			//拿id的属性值  去数据库匹配
			var res = goodlist.filter(function(item, index) {
				return item.id == obj.id


			})
			res.forEach(function(items, idx) {

				god.innerHTML += '<li  class="goods1"><img src="' + items.url + '">' +
					'<p>姓名：' + items.name + '</p>' +
					'<p>价格：' + items.price + '</p>' +
					'<p>年龄：' + items.age + '</p>' +
					'</li>'
			})
		</script>
	</body>
</html>
